<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection">
		<meta content="email=no" name="format-detection">
		<title>phone模板</title>
		<link rel="stylesheet" type="text/css" href="common.css"/>
		<link rel="stylesheet" type="text/css" href="box-flex.css"/>
		<link rel="stylesheet" type="text/css" href="layer.css"/>
		<script src="webRem.js" type="text/javascript" charset="utf-8"></script>
		<script src="jquery1.42.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="layer.js" type="text/javascript" charset="utf-8"></script>
		<script src="wilddog-auth.js" type="text/javascript" charset="utf-8"></script>
		<script src="wilddog-sync.js" type="text/javascript" charset="utf-8"></script>
		<!--<script src = "https://cdn.wilddog.com/sdk/js/2.0.0/wilddog-auth.js"></script>-->
		<!--<script src = "https://cdn.wilddog.com/sdk/js/2.0.0/wilddog-sync.js"></script>-->
		<style type="text/css">		
			*{ margin: 0; padding: 0; font-size: .3rem;}
			.list-inquire{margin: 2rem 0;}
			.checkValue{height: .6rem; border: 1px solid #ccc; padding-left: 4px; margin-right: .1rem;}
			.checkBtn{height: .6rem; background: #000000; color: #FFFFFF; width: 1rem; border: 0; border-radius: 5px;}
			.btn-inquire p{width: 2rem; height: 2rem; font-size: .3rem; background: #000000; border-radius: 50%; text-align: center; line-height: 2rem; color: #FFFFFF;}
			.layerCcss{ width: 100%; height: .5rem; border: 1px solid #CCCCCC; margin-bottom: .1rem;padding-left: 4px;}
		</style>
	</head>
	<body class="page">
		<div class="contain flex flex-v">
			<div class="list-inquire flex flex-1 flex-v flex-pack-center flex-align-center">
				<div class="searchValue">&nbsp;</div>
				<div class="flex flex-h">
					<input class="checkValue" type="text" placeholder="请输入号码" style="width:4rem;" />
					<input class="checkBtn" type="button" value="查询" />
				</div>
				<div class="flex flex-1 shareNum" style="padding: .2rem 1rem 0 0; color: #666"></div>
			</div>
			<div class="btn-inquire flex flex-1 flex-pack-center flex-align-start">
				<p class="clickRec">记录</p>			
			</div>
		</div>
		<script type="text/javascript">

		var config = {
					authDomain:"ofopassword.wilddogio.com",
					syncURL: "https://ofopassword.wilddogio.com"
				};
				wilddog.initializeApp(config);
				var ref = wilddog.sync().ref();
				var numbers= null;
				ref.child('number').on("child_added",function(snapshot){
					 numbers= parseInt(snapshot.val());
					$(".shareNum").html("被共享的数量为"+numbers);
				});
			$(function(){
				
				$(".clickRec").click(function(){
					var domHtml='<p style="text-align:left; padding:.1rem 0">请输入你的信息：</p><input type="text" class="layerCcss layer-o" placeholder="请输入帐号"></input><input type="text" class="layerCcss layer-t" placeholder="请输入密码"></input>'				
					 //询问框
					  layer.open({
					    content: domHtml
					    ,btn: ['确定', '关闭']
					    ,yes: function(index){
					    	var layerOne=$(".layer-o").val();
							var layerTwo=$(".layer-t").val();
							var text={};
							text[layerOne]=layerTwo;
							ref.child('passwordGroup').child(layerOne).set(text);

                             if (numbers >= 1000){
                               ref.child('number').set({
								'number':numbers+1
							  });
                              numbers += 1;
                             $(".shareNum").html("被共享的数量为"+(numbers+1));
                             }




					      	layer.close(index);
					      	layer.open({
							    content: '谢谢您的分享,祝您工作愉快!'
							    ,skin: 'msg'
							    ,time: 2 //2秒后自动关闭
							 });
					    }
					  });
				});
				
				$(".checkBtn").click(function(){
				$(".searchValue").html("正在查询...");
					var layerObj=$(".checkValue").val();
					var flag=false;
					show();
					setTimeout(function(){
						if(flag==false){
							$(".searchValue").html("未被共享,亲靠你了!");
						}
					},2000);
					function show(){
						ref.child('passwordGroup').child(layerObj).on("child_added",function(snapshot){
							var text = snapshot.val();						
							$(".searchValue").html(text);
							flag=true;												
						});
					};
				})
			})
		</script>


	</body>
</html>
